package com.example.movie.service;

import com.example.movie.model.Movie;
import com.example.movie.repository.MovieRepository;
import com.google.common.collect.Lists;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MovieService {
	
	@Resource
	MovieRepository movieRepository;
	
	
	public Integer saveMovie(Movie movie) {
		movieRepository.save(movie);
		return movie.getId();
	}
	
	public List<Movie> listMovie() {
		return Lists.newArrayList(movieRepository.findAll());
	}
	
	public Integer removeMovie(Integer id) {
		movieRepository.deleteById(id);
		return id;
	}
}
